package cn.wk.dao.impl;

import cn.wk.dao.UserDao;
import cn.wk.util.JDBCUtil;
import org.springframework.jdbc.core.JdbcTemplate;

public class UserDaoImpl implements UserDao {
    private JdbcTemplate template=new JdbcTemplate(JDBCUtil.getDataSource());
    @Override
    public int login(String roel, String no, String pwd) {
        String sql="";
        if(roel.equals("管理员")){
            sql="select count(*) from admins where ano=? and apwd=?";
        }else if(roel.equals("教师")){
            sql="select count(*) from teacher where tno=? and tpwd=?";
        }else{
            sql="select count(*) from stuinfo where stuno=? and stupwd=?";
        }
       int b= template.queryForObject(sql,Integer.class,no,pwd);
        return b;
    }
}
